<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/6/20 0020
  Time: 9:57
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>详情</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/layui.css">
</head>
<body>
<form class="layui-form">
    <input type="hidden" name="id" value="${customer_loss.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">客户名称</label>
        <div class="layui-input-inline">
            <input type="text" value="${customer_loss.customer.name}" autocomplete="off" placeholder="" class="layui-input" readonly="readonly">
            <a style="background: lightseagreen" href="${pageContext.request.contextPath}/customer/follow_up_add.jsp">客户信息</a>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">最后一次下单时间</label>
        <div class="layui-input-inline">
            <input type="text" name="last_order_time" value="<fmt:formatDate value="${customer_loss.last_order_time}" pattern="yyyy-MM-dd"></fmt:formatDate> " autocomplete="off" placeholder="" class="layui-input">
            <a style="background: lightseagreen" href="${pageContext.request.contextPath}/customer/follow_up_add.jsp">查看历史订单</a>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">采取的措施</label>
        <div class="layui-input-inline">
            <textarea cols="40" name="measure" autocomplete="off" placeholder="请输入采取的措施" class="layui-textarea">${customer_loss.measure}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">流失时间</label>
        <div class="layui-input-inline">
            <input type="text" name="loss_date" value="<fmt:formatDate value="${customer_loss.loss_date}" pattern="yyyy-MM-dd"></fmt:formatDate>" autocomplete="off" placeholder="" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">流失原因</label>
        <div class="layui-input-inline">
            <textarea cols="40" name="reason"  autocomplete="off" placeholder="请输入流失原因，未流失可不填写" class="layui-textarea">${customer_loss.reason}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">客户状态</label>
        <div class="layui-input-inline">
            <select name="status">
                <option value="0" <c:if test="${customer_loss.status=='0'}">selected</c:if>>将要流失</option>
                <option value="1" <c:if test="${customer_loss.status=='1'}">selected</c:if>>确认流失</option>
                <option value="2" <c:if test="${customer_loss.status=='2'}">selected</c:if>>挽回客户</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item" style="width: 450px">
        <div class="layui-input-block">
            <button lay-submit lay-filter="update" class="layui-btn">更新</button>
        </div>
    </div>
</form>

<script src="${pageContext.request.contextPath}/static/layui/layui.js"></script>
<script>
    //一般直接写在一个js文件中
    layui.use(['layer', 'form','jquery'], function(){
        var layer = layui.layer
            ,form = layui.form;
        var $=layui.$;
        //异步提交表单
        form.on("submit(update)",function (data) {
            $.post("${pageContext.request.contextPath}/customer/lossupdate",data.field,function (result) {
                if (result.code==0){
                    layer.msg("更新成功！");
                    //刷新父窗口内容
                    parent.layui.table.reload("customerlossTable",{
                        page:{
                            curr:1
                        }
                    })
                    //关闭弹出
                    var index=parent.layer.getFrameIndex(window.name);//先得到当前frame层的索引
                    parent.layer.close(index);//再执行关闭
                }
            },"json")
            return false;//阻止表单提交
        })
    });
</script>

</body>
</html>
